package com.example.springbootmybatisplus.utils;

/**
 * @ClassName UnderlineToCamelUtil
 * @Description: TODO
 * @Author: Sunny
 * @Create: 2023-12-26 15:31
 * @Version 1.0
 **/
public class UnderlineToCamelUtil {
    public static String underlineToCamel(String underlineString) {
        StringBuilder camelString = new StringBuilder();
        boolean nextUpperCase = false;
        for (int i = 0; i < underlineString.length(); i++) {
            char c = underlineString.charAt(i);
            if (c == '_') {
                nextUpperCase = true;
            } else {
                if (nextUpperCase) {
                    camelString.append(Character.toUpperCase(c));
                    nextUpperCase = false;
                } else {
                    camelString.append(Character.toLowerCase(c));
                }
            }
        }
        return camelString.toString();
    }

    public static void main(String[] args) {
        System.out.println(underlineToCamel("QWE_WWW_USER"));
    }
}